<template>
  <view class="content">
    <view class="searchBox">
      <image class="img" src="../../static/img/magnifier.png" mode=""></image>
      <input class="ipt" placeholder-style="color:rgba(0,0,0,0.4);font-size:24rpx" placeholder="输入门店名称" v-model="queryInfo.search_data" />
      <view class="searchBtn" @tap="get_store_list">
        搜索
      </view>
    </view>
    <view class="list" v-if="show_state == '0'">
      <view class="item" v-for="(item,i) in list" :key="i" @tap="goHome(item.store_name,item.store_id)">
        <view class="name">
          {{item.store_name}}
        </view>
        <view class="address">
          {{item.province}} {{item.city}} {{item.area}} {{item.address}}
        </view>
        <image class="radioImg" src="../../static/img/radio.png" mode=""></image>
      </view>
    </view>
    <view  class="list" v-if="show_state == '1'">
      <view class="itemVox" @tap="goHome()">
        <view class="name" style="width: 80%;">
          {{shoDetail}}
        </view>
        <image class="radioImg" src="../../static/img/radio.png" mode=""></image>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        queryInfo:{
          order_sn:'',
          search_data:''
        },
          list:[
            
          ],
          store_id:'',
          show_state:'',
          shoDetail:''
      };
    },
    onLoad(obj) {
      this.queryInfo.order_sn = obj.order_sn
      this.get_store_list()
    },
    methods: {
      goHome(i,id) {
        if(this.show_state == '0') {
          uni.setStorageSync('name', i);
          uni.setStorageSync('store_id', id);
          uni.navigateBack({
            delta:1
          })
        }
        if(this.show_state == '1') {
           uni.setStorageSync('name', '商家自定义门店');
           uni.setStorageSync('store_id', this.store_id);
           uni.navigateBack({
            delta:1
          })
        }
      },
      async get_store_list() {
        const {data:res} = await uni.$http.post('join_order/get_store_list',this.queryInfo)
        if(res.code != 1) {
          this.toast.msg(res.msg)
          return
        }
        this.list = res.data.data
        this.show_state = res.data.show_state
        if(res.data.show_state == 1) {
          this.shoDetail = res.data.data
          this.store_id = res.data.store_id
        }
      }
    }
  }
</script>

<style lang="scss">
  .content {
    min-height: 100vh;
    background-color: #F2F3F6;

    .searchBox {
      position: relative;
      box-sizing: border-box;
      display: flex;
      align-items: center;
      height: 104rpx;
      background-color: #fff;
      padding: 22rpx 36rpx 22rpx 32rpx;

      .img {
        position: absolute;
        top: 30rpx;
        left: 48rpx;
        width: 40rpx;
        height: 40rpx;
      }

      .ipt {
        box-sizing: border-box;
        width: 600rpx;
        height: 60rpx;
        background: #F2F3F6;
        border-radius: 124rpx 124rpx 124rpx 124rpx;
        padding-left: 72rpx;
      }

      .searchBtn {

        font-size: 30rpx;
        font-family: PingFang SC-Medium, PingFang SC;
        font-weight: 500;
        color: #7D81A9;
        margin-left: 20rpx;
      }
    }

    .list {
      padding-left: 40rpx;
      box-sizing: border-box;
      background-color: #fff;
      .itemVox {
        position: relative;
        padding: 24rpx;
          font-size: 28rpx;
        .radioImg {
          position: absolute;
          top: 48rpx;
          right: 40rpx;
          width: 36rpx;
          height: 36rpx;
          
        }
      }
      .item {
        position: relative;
        padding: 24rpx 0;
        box-sizing: border-box;
        height: 132rpx;
        border-bottom: 2rpx solid #F2F3F6;

        .name {
          font-size: 28rpx;
          font-family: PingFang SC-Medium, PingFang SC;
          font-weight: 550;
          color: #000000;
          margin-bottom: 10rpx;
        }

        .address {
          font-size: 24rpx;
          font-family: PingFang SC-Regular, PingFang SC;
          font-weight: 400;
          color: rgba(0, 0, 0, 0.6);
        }

        .radioImg {
          position: absolute;
          top: 48rpx;
          right: 40rpx;
          width: 36rpx;
          height: 36rpx;
        }
      }
    }
  }
</style>